home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / emsif24a.zip / EMSIF.H < prev    next >
C/C++ Source or Header  |  1993-06-21  |  7KB  |  223 lines

  1. /***************************************************************************
  2. *   EMSIF.H                                                                *
  3. *   HEADER FOR EMSIF                                                       *
  4. *   OS:        DOS                                                         *
  5. *   VERSION:   3.0                                                         *
  6. *   DATE:      06/21/93                                                    *
  7. *                                                                          *
  8. *   Copyright (c) 1991, 1993 James W. Birdsall. All Rights Reserved.       *
  9. *                                                                          *
  10. ***************************************************************************/
  11.  
  12. #ifndef EMSIF_H
  13. #define EMSIF_H
  14.  
  15. /*
  16. ** system includes <>
  17. */
  18.  
  19. /*
  20. ** custom includes ""
  21. */
  22.  
  23. /*
  24. ** local #defines
  25. */
  26.  
  27. #ifndef __cplusplus
  28.  
  29. /* fake an invalidate function */
  30. #define _EMMinval()         if (_EMMframecache != 0) _EMMenc(); else _EMMdisc()
  31.  
  32. /*
  33. ** EMMicopyfrom() and EMMicopyto() used to be functions, these
  34. ** macros provided for compatibility.
  35. */
  36. #define EMMicopyfrom(n,e,b,h,f,d)  _EMMicopyfrom((n),(e),(b),(h),(f),(d),(b))
  37. #define EMMicopyto(n,e,b,s,h,f)    _EMMicopyto((n),(e),(b),(s),(h),(f),(b))
  38.  
  39. #endif /* !__cplusplus */
  40.  
  41.  
  42. /* error returns */
  43. #define EMMOOPS       -1
  44. #define NOEMM         -2
  45.  
  46. /* EMM library errors */
  47.  
  48. #define EMM_BADVERS         0x40
  49. #define EMM_BADOFFSET       0x41
  50. #define EMM_NOFRAME         0x42
  51. #define EMM_NOINIT          0x43
  52. #define EMM_FEWFRAMES       0x44
  53. #define EMM_NOSR            0x45
  54. #define EMM_MEMNULL         0x46
  55. #define EMM_ELTOOBIG        0x47
  56. #define EMM_SKTOOBIG        0x48
  57.  
  58. /* EMM driver errors */
  59.  
  60. #define EMM_SOFTERROR       0x80
  61. #define EMM_HARDERROR       0x81
  62. #define EMM_BUSY            0x82
  63. #define EMM_BADHANDLE       0x83
  64. #define EMM_UNIMP           0x84
  65. #define EMM_NOFREEHAN       0x85
  66. #define EMM_CONTEXTERR      0x86
  67. #define EMM_WAYTOOBIG       0x87
  68. #define EMM_TOOBIG          0x88
  69. #define EMM_TOOSMALL        0x89
  70. #define EMM_BADLOGPAGE      0x8A
  71. #define EMM_BADFRAMENO      0x8B
  72. #define EMM_HSTATESAVFULL   0x8C
  73. #define EMM_MSTATESAVFULL   0x8D
  74. #define EMM_MSTATERESTERR   0x8E
  75. #define EMM_UNIMPSUB        0x8F
  76. #define EMM_BADATTRIB       0x90
  77. #define EMM_NOFEATURE       0x91
  78. #define EMM_SRCOVERWRITE    0x92
  79. #define EMM_BADLENGTH       0x93
  80. #define EMM_CONEMSOVERLAP   0x94
  81. #define EMM_OFFPAGE         0x95
  82. #define EMM_TOOLONG         0x96
  83. #define EMM_EMSEMSOVERLAP   0x97
  84. #define EMM_LOST            0x98
  85. #define EMM_UNUSED          0x99
  86. #define EMM_BADALTREG       0x9A
  87. #define EMM_NOFREEALTREG    0x9B
  88. #define EMM_NOALTREG        0x9C
  89. #define EMM_BADALTREG2      0x9D
  90. #define EMM_NODEDDMA        0x9E
  91. #define EMM_BADDEDDMA       0x9F
  92. #define EMM_UNKNAME         0xA0
  93. #define EMM_NAMETAKEN       0xA1
  94. #define EMM_ADDRWRAP        0xA2
  95. #define EMM_BADPTR          0xA3
  96. #define EMM_FORBIDDENFUNC   0xA4
  97.  
  98.  
  99. /*
  100. ** misc: copyright strings, version macros, etc.
  101. */
  102.  
  103. /*
  104. ** typedefs
  105. */
  106.  
  107. typedef struct a {             /* return type from EMMgetframeaddr() */
  108.     unsigned int segaddr;
  109.     unsigned int frameno;
  110. } frameinfo;
  111.  
  112.  
  113. /*
  114. ** global variables
  115. */
  116.  
  117. #if (defined(_MSC_VER) && (_MSC_VER == 800) && defined(M_I86HM))
  118.  
  119. /*
  120. ** This little bit of cruft is necessary for the benefit of MSC 8.0
  121. ** (found in Microsoft Visual C++ 1.0) in huge model, because otherwise
  122. ** it loses track of the fact that these variables are in a far data segment.
  123. */
  124.  
  125. extern unsigned char const __far _EMMerror;       /* EMS error variable */
  126. extern unsigned char const __far _EMMversion;     /* EMS version, BCD */
  127. extern unsigned char const __far _EMMframecache;  /* caching flag, copy funcs */
  128.  
  129. extern char const __far emsif_vers_vers[];
  130. extern char const __far emsif_vers_date[];
  131. extern char const __far emsif_vers_time[];
  132.  
  133. #else
  134.  
  135. extern unsigned char const _EMMerror;       /* EMS error variable */
  136. extern unsigned char const _EMMversion;     /* EMS version, BCD */
  137. extern unsigned char const _EMMframecache;  /* caching flag for copy funcs */
  138.  
  139. extern char const emsif_vers_vers[];
  140. extern char const emsif_vers_date[];
  141. extern char const emsif_vers_time[];
  142.  
  143. #endif
  144.  
  145.  
  146. /*
  147. ** function prototypes
  148. */
  149.  
  150. #ifdef __cplusplus
  151.  
  152. extern "C"
  153. {
  154. #define extern
  155.  
  156. #endif /* __cplusplus */
  157.  
  158. extern int EMMlibinit(void);
  159. extern int EMMgetversion(void);
  160.  
  161. extern unsigned long EMMcoreleft(void);
  162. extern int EMMalloc(unsigned long bytes);
  163. extern int EMMrealloc(int handle, unsigned long bytes);
  164. extern int EMMfree(int handle);
  165.  
  166. extern int EMMgetnumframe(void);
  167. extern unsigned int EMMgetsinfraddr(int frame);
  168. extern int EMMgetframeaddr(frameinfo *buffer);
  169. extern int EMMmappage(int frameno, int handle, int logpage);
  170. extern int EMMunmapframe(int frameno);
  171. extern int EMMallocpages(int pages);
  172. extern int EMMreallocpages(int handle, int pages);
  173.  
  174. extern int EMMcopyto(unsigned long copylen, unsigned char far *source,
  175.                                             int handle, unsigned long foffset);
  176. extern int EMMcopyfrom(unsigned long copylen, int handle,
  177.                                unsigned long foffset, unsigned char far *dest);
  178. extern int _EMMicopyto(unsigned long nelem, int elsize,
  179.                    unsigned int srcskip, unsigned char far *source,
  180.                    int handle, unsigned long foffset, unsigned int destskip);
  181. extern int _EMMicopyfrom(unsigned long nelem, int elsize,
  182.                    unsigned int srcskip, int handle, unsigned long foffset,
  183.                    unsigned char far *dest, unsigned int destskip);
  184.  
  185. extern int EMMsrinit(void *(*mallocfunc)(size_t));
  186. extern void *EMMsave(void);
  187. extern int EMMrestore(void *saveblock);
  188.  
  189. extern int EMMsetname(int handle, char *name);
  190. extern int EMMgetname(int handle, char *name);
  191.  
  192. extern void _EMMenc(void);
  193. extern void _EMMdisc(void);
  194.  
  195. #ifdef __cplusplus
  196.  
  197. }
  198. #undef extern
  199.  
  200. inline void _EMMinval()
  201. {
  202.     if (_EMMframecache != 0) _EMMenc(); else _EMMdisc();
  203. }
  204.  
  205. inline int EMMicopyfrom(unsigned long nelem, int elsize,
  206.                         unsigned int skip, int handle, unsigned long foffset,
  207.                         unsigned char far *dest)
  208. {
  209.     return _EMMicopyfrom(nelem, elsize, skip, handle, foffset, dest, skip);
  210. }
  211.  
  212. inline int EMMicopyto(unsigned long nelem, int elsize,
  213.                       unsigned int skip, unsigned char far *source,
  214.                       int handle, unsigned long foffset)
  215. {
  216.     return _EMMicopyto(nelem, elsize, skip, source, handle, foffset, skip);
  217. }
  218.  
  219. #endif /* __cplusplus */
  220.  
  221. #endif /* EMSIF */
  222.  
  223.